<template>
  <view v-if="shenheStatus == 0" class="shareOrder">
    <view class="header-tabs">
      <u-tabs
        :list="status_list"
        :current="current"
        active-color="#FA230A"
        item-width="25%"
        @change="tabsChange"
        height="44"
        inactive-color="#262626"
      ></u-tabs>
    </view>
    <view class="item" v-for="(item, index) in orderList" :key="index">
      <orderItem :order="item" ref="order"></orderItem>
    </view>
    <view class="empty" style="padding-top: 50rpx" v-if="!orderList.length">
      <u-empty mode="data"></u-empty>
    </view>
  </view>
  <Shenhe v-else-if="shenheStatus == 1"></Shenhe>
</template>

<script>
import Shenhe from "@/components/shenhe/shenhe";
import orderItem from "./components/order-item.vue";

export default {
  components: {
    orderItem,
    Shenhe
  },
  data() {
    return {
      status_list: [
        {
          name: this.$t("person.cashStatus1"),
          status: 0
        },
        {
          name: this.$t("person.status1"),
          status: 1
        },
        {
          name: this.$t("person.status6"),
          status: 2
        },
        {
          name: this.$t("person.status4"),
          status: 3
        }
      ],
      // 订单列表
      orderList: [],
      // 当前加载页面
      page: 1,
      // 是否加载完毕
      noMore: false,
      // 当前tab所处项
      current: 0,
      yinbao: ""
    };
  },
  onLoad() {
    this.getList();
  },
  methods: {
    tabsChange(e) {
      this.page = 1;
      this.orderList = [];
      this.noMore = false;
      this.current = e;
      this.getList();
    },
    // 获取订单列表
    async getList() {
      let params = {
        page: this.page
      };

      params.status = this.current - 1;

      const res = await this.$allrequest.share.videoShareOrder(params, true);
      if (res.code == 0) {
        this.orderList = [...this.orderList, ...res.data.data];
        if (this.orderList.length >= res.data.row_count) {
          this.noMore = true;
        } else {
          this.noMore = false;
        }
      }
    }
  },
  onReachBottom() {
    if (!this.noMore) {
      this.page++;
      this.getList();
    }
  }
};
</script>

<style scoped lang="less">
.shareOrder {
  min-height: 100vh;
  padding-top: 90rpx;
  background-color: #f2f2f2;
  font-family: PingFang SC;
  color: #262626;
}
.header-tabs {
  width: 100%;
  padding-top: 20rpx;
  height: 90rpx;
  // line-height: 90rpx;
  background: #ffffff;
  position: fixed;
  top: 0;
  z-index: 1000;
  left: 0;
}
.item {
  margin-bottom: 24rpx;
}
</style>
